package com.shiguiwu.springmybatis.spring.imports;

import com.shiguiwu.springmybatis.spring.imports.config.ImportConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Import;

/**
 * @description: 为什么有import注解，因为我们需要指定特殊的类，而不需要全部到注册进容器中
 * @author: stone
 * @date: Created by 2021/9/29 15:51
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.imports
 */
//1，import导入普通的类型
//@Import(ImportService.class)

//================================
//2，导入配置类
@Import(ImportConfig.class)
//================================


//3.导入带有扫描注解的类
//@Import(BeanComponentScan.class)

//================================
//4，导入 实现   ImportBeanDefinitionRegistrar的类
//@Import(MyImportBeanDefinitionRegistrar.class)


//5,导入ImportSelector的子类,也能注册进来
//@Import(MyImportSelector.class)
public class ImportTests {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ImportTests.class);

        String[] names = context.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name + " ===> " + context.getBean(name));
        }
    }
}
